package com.mooral.context;

import javax.servlet.http.HttpSession;

import com.mooral.bean.User;
import com.mooral.dataAccess.DataAccessConnection;
import com.mooral.web.constant.Constants;

public class Context extends Constants {

	protected String sessionId;
	protected String applicationName;	
	protected HttpSession session;
	
	
	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}

	public User getUser() {
		return (User)session.getAttribute("mooralUser");
	}

	public void setUser(User user) {
		session.setAttribute("mooralUser", user);
	}

	public void removeUser(){
		session.removeAttribute("mooralUser");
	}
	
	public DataAccessConnection getDataAccessConnection() throws Exception {
    	return new DataAccessConnection(DA_ICLOOCKUP_NAME,DA_DATASOURCE_NAME,DA_USER_NAME,DA_PWD);
    }

    public void disposeDataAccessConnection(DataAccessConnection dataAccessConnection) throws Exception {
    	dataAccessConnection.disposeConnection();
    	dataAccessConnection = null;
    }

    public String getSessionId() {
    	return sessionId;
    }

    public void setSessionId(String sessionId) {
    	this.sessionId = sessionId;
    }

	public String getApplicationName() {
		return applicationName;
	}

	public void setApplicationName(String applicationName) {
		this.applicationName = applicationName;
	}

	
}
